home *** CD-ROM | disk | FTP | other *** search
/ HAKERIS 11 / HAKERIS 11.ISO / soft / development / Macromedia RoboHelp X5 / RoboHelpOffice.exe / Data1.cab / _6759B3C9B0A34C98BDBE9AD57262EF9B < prev    next >
Encoding:
Text File  |  2003-12-19  |  7.5 KB  |  286 lines

  1. // Macromedia
  2. // Copyright⌐ 1998-2004 eHelp« Corporation.All rights reserved.
  3. // RoboHelp_CSH.js
  4. // The Helper function for WebHelp Context Sensitive Help
  5.  
  6. //     Syntax:
  7. //     function RH_ShowHelp(hParent, a_pszHelpFile, uCommand, dwData)
  8. //
  9. //     hParent
  10. //          Reserved - Use 0
  11. //   
  12. //     pszHelpFile
  13. //          WebHelp: 
  14. //               Path to help system start page ("http://www.myurl.com/help/help.htm" or "/help/help.htm")
  15. //               For custom windows (defined in Help project), add ">" followed by the window name ("/help/help.htm>mywin")
  16. //
  17. //          WebHelp Enterprise: 
  18. //               Path to RoboEngine server ("http://RoboEngine/roboapi.asp")
  19. //               If automatic merging is turned off in RoboEngine Configuration Manager, specify the project name in the URL ("http://RoboEngine/roboapi.asp?project=myproject")
  20. //               For custom windows (defined in Help project), add ">" followed by the window name ("http://RoboEngine/roboapi.asp>mywindow")
  21. //
  22. //     uCommand
  23. //          Command to display help. One of the following:
  24. //                    HH_HELP_CONTEXT     // Displays the topic associated with the Map ID sent in dwData
  25. //                                            if 0, then default topic is displayed.                
  26. //               The following display the default topic and the Search, Index, or TOC pane. 
  27. //               Note: The pane displayed in WebHelp Enterprise will always be the window's default pane.
  28. //                    HH_DISPLAY_SEARCH 
  29. //                    HH_DISPLAY_INDEX
  30. //                    HH_DISPLAY_TOC
  31. //
  32. //     dwData
  33. //          Map ID associated with the topic to open (if using HH_HELP_CONTEXT), otherwise 0
  34. //
  35. //     Examples:
  36. //     <p>Click for <A HREF='javascript:RH_ShowHelp(0, "help/help.htm", 0, 10)'>Help</A> (map number 10)</p>
  37. //     <p>Click for <A HREF='javascript:RH_ShowHelp(0, "help/help.htm>mywindow", 0, 100)'>Help in custom window (map number 100)</A></p>
  38.  
  39.  
  40. var gbNav6=false;
  41. var gbNav61=false;
  42. var gbNav4=false;
  43. var gbIE4=false;
  44. var gbIE=false;
  45. var gbIE5=false;
  46. var gbIE55=false;
  47.  
  48. var gAgent=navigator.userAgent.toLowerCase();
  49. var gbMac=(gAgent.indexOf("mac")!=-1);
  50. var gbSunOS=(gAgent.indexOf("sunos")!=-1);
  51. var gbOpera=(gAgent.indexOf("opera")!=-1);
  52.  
  53. var HH_DISPLAY_TOPIC = 0;
  54. var HH_DISPLAY_TOC = 1;
  55. var HH_DISPLAY_INDEX = 2;
  56. var HH_DISPLAY_SEARCH = 3;
  57. var HH_HELP_CONTEXT = 15;
  58.  
  59. var gVersion=navigator.appVersion.toLowerCase();
  60.  
  61. var gnVerMajor=parseInt(gVersion);
  62. var gnVerMinor=parseFloat(gVersion);
  63.  
  64. gbIE=(navigator.appName.indexOf("Microsoft")!=-1);
  65. if(gnVerMajor>=4)
  66. {
  67.     if(navigator.appName=="Netscape")
  68.     {
  69.         gbNav4=true;
  70.         if(gnVerMajor>=5)
  71.             gbNav6=true;
  72.     }
  73.     gbIE4=(navigator.appName.indexOf("Microsoft")!=-1);
  74. }
  75. if(gbNav6)
  76. {
  77.     document.gnPageWidth=innerWidth;
  78.     document.gnPageHeight=innerHeight;
  79.     var nPos=gAgent.indexOf("netscape");
  80.     if(nPos!=-1)
  81.     {
  82.         var nVersion=parseFloat(gAgent.substring(nPos+10));
  83.         if(nVersion>=6.1)
  84.             gbNav61=true;
  85.     }
  86. }else if(gbIE4)
  87. {
  88.     var nPos=gAgent.indexOf("msie");
  89.     if(nPos!=-1)
  90.     {
  91.         var nVersion=parseFloat(gAgent.substring(nPos+5));
  92.         if(nVersion>=5)
  93.             gbIE5=true;
  94.         if(nVersion>=5.5)
  95.             gbIE55=true;
  96.     }
  97. }
  98.  
  99. function RH_ShowHelp(hParent, a_pszHelpFile, uCommand, dwData)
  100. {
  101.     // this function only support WebHelp
  102.     var strHelpPath = a_pszHelpFile;
  103.     var strWnd = "";
  104.     var nPos = a_pszHelpFile.indexOf(">");
  105.     if (nPos != -1)
  106.     {
  107.         strHelpPath = a_pszHelpFile.substring(0, nPos);
  108.         strWnd = a_pszHelpFile.substring(nPos+1); 
  109.     }
  110.     if (isServerBased(strHelpPath))
  111.         RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData);
  112.     else
  113.         RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData);
  114. }
  115.  
  116. function RH_ShowWebHelp_Server(hParent, strHelpPath, strWnd, uCommand, dwData)
  117. {
  118.     // hParent never used.
  119.     ShowWebHelp_Server(strHelpPath, strWnd, uCommand, dwData);
  120. }
  121.  
  122. function RH_ShowWebHelp(hParent, strHelpPath, strWnd, uCommand, dwData)
  123. {
  124.     // hParent never used.
  125.     ShowWebHelp(strHelpPath, strWnd, uCommand, dwData);
  126. }
  127.  
  128.  
  129. function ShowWebHelp_Server(strHelpPath, strWnd, uCommand, nMapId)
  130. {
  131.     var a_pszHelpFile = "";
  132.     if (uCommand == HH_HELP_CONTEXT)
  133.     {
  134.         if (strHelpPath.indexOf("?") == -1)
  135.             a_pszHelpFile = strHelpPath + "?ctxid=" + nMapId;
  136.         else
  137.             a_pszHelpFile = strHelpPath + "&ctxid=" + nMapId;
  138.     }
  139.     else
  140.     {
  141.         if (strHelpPath.indexOf("?") == -1)
  142.             a_pszHelpFile = strHelpPath + "?ctxid=0";
  143.         else
  144.             a_pszHelpFile = strHelpPath + "&ctxid=0";
  145.     }
  146.  
  147.     if (strWnd)
  148.         a_pszHelpFile += ">" + strWnd;
  149.  
  150.     if (gbIE4)
  151.     {
  152.         a_pszHelpFile += "&cmd=newwnd&rtype=iefrm";
  153.         loadData(a_pszHelpFile);
  154.     }
  155.     else if (gbNav4)
  156.     {
  157.         a_pszHelpFile += "&cmd=newwnd&rtype=nswnd";
  158.         var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
  159.         window.open(a_pszHelpFile, "__webCshStub", sParam);
  160.     }
  161.     else
  162.     {
  163.         var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
  164.         if (gbIE5)
  165.             window.open("about:blank", "__webCshStub", sParam);
  166.         window.open(a_pszHelpFile, "__webCshStub");
  167.     }
  168. }
  169.  
  170.  
  171. function ShowWebHelp(strHelpPath, strWnd, uCommand, nMapId)
  172. {
  173.     var a_pszHelpFile = "";
  174.     if (uCommand == HH_DISPLAY_TOPIC)
  175.     {
  176.         a_pszHelpFile = strHelpPath + "#<id=0";
  177.     }
  178.     if (uCommand == HH_HELP_CONTEXT)
  179.     {
  180.         a_pszHelpFile = strHelpPath + "#<id=" + nMapId;
  181.     }
  182.     else if (uCommand == HH_DISPLAY_INDEX)
  183.     {
  184.         a_pszHelpFile = strHelpPath + "#<cmd=idx";
  185.     }
  186.     else if (uCommand == HH_DISPLAY_SEARCH)
  187.     {
  188.         a_pszHelpFile = strHelpPath + "#<cmd=fts";
  189.     }
  190.     else if (uCommand == HH_DISPLAY_TOC)
  191.     {
  192.         a_pszHelpFile = strHelpPath + "#<cmd=toc";
  193.     }
  194.     if (strWnd)
  195.         a_pszHelpFile += ">>wnd=" + strWnd;
  196.  
  197.     if (a_pszHelpFile)
  198.     {
  199.         if (gbIE4)
  200.             loadData(a_pszHelpFile);
  201.         else if (gbNav4)
  202.         {
  203.             var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
  204.             window.open(a_pszHelpFile, "__webCshStub", sParam);
  205.         }
  206.         else
  207.         {
  208.             var sParam = "left="+screen.width+",top="+screen.height+",width=100,height=100";
  209.             if (gbIE5)
  210.                 window.open("about:blank", "__webCshStub", sParam);
  211.             window.open(a_pszHelpFile, "__webCshStub");
  212.         }
  213.     }
  214. }
  215.  
  216. function isServerBased(a_pszHelpFile)
  217. {
  218.     if (a_pszHelpFile.length > 0)
  219.     {
  220.         var nPos = a_pszHelpFile.lastIndexOf('.');
  221.         if (nPos != -1 && a_pszHelpFile.length >= nPos + 4)
  222.         {
  223.             var sExt = a_pszHelpFile.substring(nPos, nPos + 4);
  224.             if (sExt.toLowerCase() == ".htm")
  225.             {
  226.                 return false;
  227.             }
  228.         }
  229.     }
  230.     return true;
  231. }
  232.  
  233. function getElement(sID)
  234. {
  235.     if(document.getElementById)
  236.         return document.getElementById(sID);
  237.     else if(document.all)
  238.         return document.all(sID);
  239.     return null;
  240. }
  241.  
  242. function loadData(sFileName)
  243. {
  244.     if(!getElement("dataDiv"))
  245.     {
  246.         if(!insertDataDiv())
  247.         {
  248.             gsFileName=sFileName;
  249.             return;
  250.         }
  251.     }
  252.     var sHTML="";
  253.     if(gbMac)
  254.         sHTML+="<iframe name=\"__WebHelpCshStub\" src=\""+sFileName+"\"></iframe>";
  255.     else
  256.         sHTML+="<iframe name=\"__WebHelpCshStub\" style=\"visibility:hidden;width:0;height:0\" src=\""+sFileName+"\"></iframe>";
  257.     
  258.     var oDivCon=getElement("dataDiv");
  259.     if(oDivCon)
  260.     {
  261.         if(gbNav6)
  262.         {
  263.             if(oDivCon.getElementsByTagName&&oDivCon.getElementsByTagName("iFrame").length>0)
  264.             {
  265.                 oDivCon.getElementsByTagName("iFrame")[0].src=sFileName;
  266.             }
  267.             else
  268.                 oDivCon.innerHTML=sHTML;
  269.         }
  270.         else
  271.             oDivCon.innerHTML=sHTML;
  272.     }
  273. }
  274.  
  275. function insertDataDiv()
  276. {
  277.     var sHTML="";
  278.     if(gbMac)
  279.         sHTML+="<div id=dataDiv style=\"display:none;\"></div>";
  280.     else
  281.         sHTML+="<div id=dataDiv style=\"visibility:hidden\"></div>";
  282.  
  283.     document.body.insertAdjacentHTML("beforeEnd",sHTML);
  284.     return true;
  285. }
  286.